<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      /* 常规reset动作 */
      * {
        margin: 0;
        padding: 0;
      }

      html,
      body {
        width: 100%;
        height: 100%;
      }

      ul,
      ol,
      li {
        list-style-type: none;
      }

      /* tabbox */
    </style>
    <link rel="stylesheet" href="./tab.css" />
  </head>

  <body>
    <div id="box1"></div>
    <hr />
    <div id="box2"></div>

    <script src="./tabx2.js"></script>
    <script>
      const tb1 = new TabBox(
        document.querySelector("#box1"), 
        {
          tabs: [
            { tab: "汽车", content: "auto" },
            { tab: "房产", content: "house" },
            { tab: "编程", content: "IT" },
          ],
        }
      );

      const tb2 = new TabBox(
        document.querySelector("#box2"), 
        {
          // tabs:["A","B","C"]
          tabs: [
            { tab: "A", content: "contenta" },
            { tab: "B", content: "contentb" },
            { tab: "C", content: "contentc" },
            { tab: "D", content: "contentd" },
          ],
          boxStyles: {
            width: "1000px",
            height: "700px",
          },
        }
      );

      let currentIndex = 0;
      setInterval(() => {
        currentIndex++;
        currentIndex >= 4 && (currentIndex = 0);
        tb2.switchTab(currentIndex);
      }, 1000);
      
    </script>
  </body>
</html>
